package com.example.wallpaperapp.ui.fragment;

import android.content.Context;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.wallpaperapp.R;
import com.example.wallpaperapp.adapter.HomeChoicAdapter;
import com.example.wallpaperapp.adapter.HomeRecyclerViewAdapter;
import com.example.wallpaperapp.base.BaseFragment;
import com.example.wallpaperapp.bean.HomeImageRecyclerViewBean;
import com.example.wallpaperapp.ui.activity.Activity_preview;
import com.example.wallpaperapp.ui.activity.ChoicenessActivity;
import com.example.wallpaperapp.ui.activity.PreviewActivity;
import com.example.wallpaperapp.utils.RecyclerViewSpacesItemDecoration;
import com.example.wallpaperapp.utils.ToastUtil;

import java.util.ArrayList;
import java.util.List;


public class HottestFragment extends BaseFragment {
    private RecyclerView near_recyclerview;
    private List<HomeImageRecyclerViewBean> list = new ArrayList<>();
    private ArrayList<Integer> viewIds = new ArrayList<>();
    @Override
    protected void initView(View view) {
        list.add(new HomeImageRecyclerViewBean("https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1428508144,2050166556&fm=26&gp=0.jpg"));
        list.add(new HomeImageRecyclerViewBean("https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2362401796,3477408968&fm=11&gp=0.jpg"));
        list.add(new HomeImageRecyclerViewBean("https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1405713595,3743587349&fm=26&gp=0.jpg"));
        list.add(new HomeImageRecyclerViewBean("https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=552983142,466041150&fm=11&gp=0.jpg"));
        list.add(new HomeImageRecyclerViewBean("https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1105959625,2794724649&fm=26&gp=0.jpg"));
        near_recyclerview = view.findViewById(R.id.hot_recycler);
        near_recyclerview.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
        near_recyclerview.addItemDecoration(new RecyclerViewSpacesItemDecoration(RecyclerViewSpacesItemDecoration.RIGHT_DECORATION,30));
        HomeRecyclerViewAdapter adapter = new HomeRecyclerViewAdapter(getContext(),list);
        adapter.setOnItemCickListener(new HomeRecyclerViewAdapter.MyOnItemClickListener() {
            @Override
            public void myOnItemClickListener(int position, View view) {
                Activity_preview.startActivity_preview(getActivity(), list.get(position).getImage_url());
                ToastUtil.makeText(getActivity(),"点击了第" + position + "条");
            }
        });
        near_recyclerview.setAdapter(adapter);
    }
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_hottest;
    }

    @Override
    protected void initData(Context context) {

    }

    @Override
    public void onClick(View v) {

    }
}